﻿using UnityEngine;
using System.Collections;
using System.IO;
using System;
/// <summary>
/// 网络工具类
/// </summary>
public static class NetUtil
{
    public static byte[] serializeProtoObject<T>(T obj)
    {
        using (MemoryStream m = new MemoryStream())
        {
            ProtoBuf.Serializer.Serialize<T>(m, obj);
            //  return m.GetBuffer();
            return m.ToArray();
        }
    }
    /// <summary>
    /// 反序列号 pb对象
    /// </summary>
    public static T deserialzeProtoObject<T>(byte[] bytes)
    {
        using (MemoryStream m = new MemoryStream(bytes))
        {           
            return   ProtoBuf.Serializer.Deserialize<T>(m);
        }
    }

}
